package com.panda.web.controller.py;

import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.panda.common.core.domain.R;

import com.panda.web.domain.vo.commons.CompanyJobVO;
import com.panda.web.entity.py.Job;
import com.panda.web.entity.py.JobComplaint;
import com.panda.web.mapper.py.JobComplaintMapper;
import com.panda.web.mapper.py.JobMapper;
import com.panda.web.service.py.IJobService;

import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.panda.web.utils.pageutils.PageResult;

import com.panda.common.annotation.Log;
import com.panda.common.core.controller.BaseController;
import com.panda.common.core.domain.AjaxResult;
import com.panda.common.enums.BusinessType;
import com.panda.web.domain.dto.JobDTO;
import com.panda.web.domain.vo.JobVO;

import javax.servlet.http.HttpServletResponse;


/**
 * 职位Controller
 *
 * @author cpanda
 * @date 2025-03-03
 */
@CrossOrigin
@RestController
@RequestMapping("/web/job")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class JobController extends BaseController {
    private final IJobService jobService;



    /**
     * 岗位列表
     */
    @GetMapping("/jobList")
    public PageResult<JobVO> getJobList(JobDTO dto,
                                        @RequestParam("pageNum") Integer pageNum,
                                        @RequestParam("pageSize") Integer pageSize) throws JsonProcessingException, ParseException {
        PageResult<JobVO> voList = jobService.getJobList(dto, pageNum, pageSize);
        return voList;
    }

    /**
     * 前台岗位筛选  //每天能筛20次
     */
    @GetMapping("/qt/jobListaa")
    public PageResult<JobVO> getQTJobList(JobDTO dto,
                                        @RequestParam("pageNum") Integer pageNum,
                                        @RequestParam("pageSize") Integer pageSize) throws JsonProcessingException, ParseException {
        PageResult<JobVO> voList = jobService.getQTJobList(dto, pageNum, pageSize);
        return voList;
    }


    /**
     * 前台岗位筛选  //每天能筛20次
     */
    @GetMapping("/qt/jobList")
    public PageResult<JobVO> getQTJobListAAA(JobDTO dto,
                                          @RequestParam("pageNum") Integer pageNum,
                                          @RequestParam("pageSize") Integer pageSize) throws JsonProcessingException, ParseException {
        PageResult<JobVO> voList = jobService.getQTJobAAList(dto, pageNum, pageSize);
        return voList;
    }





    /**
     * 热门推荐岗位
     */
//    @GetMapping("/hot")
    public PageResult<CompanyJobVO> getHot(JobDTO dto,
                                           @RequestParam("pageNum") Integer pageNum,
                                           @RequestParam("pageSize") Integer pageSize) {
        PageResult<CompanyJobVO> voList = jobService.getHot(dto, pageNum, pageSize);
        return voList;
    }
    /**
     * 热门推荐岗位近一周央国企企业
     */
    @GetMapping("/hot")
    public PageResult<CompanyJobVO> getHotTest(JobDTO dto,
                                           @RequestParam("pageNum") Integer pageNum,
                                           @RequestParam("pageSize") Integer pageSize) {
        PageResult<CompanyJobVO> voList = jobService.getHotTest(dto, pageNum, pageSize);
        return voList;
    }

    /**
     * 根据用户信息推荐岗位
     */
    @GetMapping(value = "/gw/open")
    public PageResult<JobVO> selectByOpenid(JobDTO dto,
                                            @RequestParam("pageNum") Integer pageNum,
                                            @RequestParam("pageSize") Integer pageSize) throws ParseException {
        PageResult<JobVO> voList = jobService.selectByOpenid(dto, pageNum, pageSize);
        return voList;
    }

    /**
     * 根据用户信息推荐岗位
     */
    @GetMapping(value = "/ces/aaaaaa")
    public PageResult<JobVO> selectBycesAAA(JobDTO dto,
                                            @RequestParam("pageNum") Integer pageNum,
                                            @RequestParam("pageSize") Integer pageSize) throws ParseException {
        PageResult<JobVO> voList = jobService.selectBycesAAA(dto, pageNum, pageSize);
        return voList;
    }



    /**
     * 投诉
     */
    @PostMapping("/complaint")
    public R complaint(@RequestBody JobComplaint complaint) {
        return R.ok(jobService.insert(complaint), 200, "ok");
    }
    /**
     * 投诉列表
     */
    @GetMapping(value = "/complaint/List")
    public PageResult<JobComplaint> selectByJobComplaint(JobComplaint complaint,
                                            @RequestParam("pageNum") Integer pageNum,
                                            @RequestParam("pageSize") Integer pageSize) throws ParseException {
        PageResult<JobComplaint> voList = jobService.selectByJobComplaint(complaint, pageNum, pageSize);
        return voList;
    }
    /**
     * 查询职位列表
     */
    @GetMapping("/list")
    public PageResult<JobVO> List(JobDTO dto,
                                  @RequestParam("pageNum") Integer pageNum,
                                  @RequestParam("pageSize") Integer pageSize) throws JsonProcessingException, ParseException {
        //返回分页信息
        PageResult<JobVO> voList = jobService.PageList(dto, pageNum, pageSize);
        return voList;
    }

    /**
     * 查询职位列表 无分页
     */
    @GetMapping("/choiceList")
    public R choiceList(JobDTO dto) throws JsonProcessingException, ParseException {
        List<JobVO> voList = jobService.choiceList(dto);
        return R.ok(voList, "ok");
    }

    /**
     * 获取职位详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) throws ParseException {
        return AjaxResult.success(jobService.selectById(id));
    }

//    /**
//     * 获取职位详细信息
//     */
//    @GetMapping(value = "/HQY/{id}")
//    public AjaxResult getInfoHQY(@PathVariable("id") Long id) throws ParseException {
//        return AjaxResult.success(jobService.selectByHQYId(id));
//    }

    /**
     * 获取职位详细信息
     */
    @GetMapping(value = "/HQY/xqxx")
    public AjaxResult getInfoHQY(JobDTO dto) throws ParseException {
        return AjaxResult.success(jobService.selectByHQYId(dto));
    }
    /**
     * 收藏
     */


}
